import time
"""
status: 是否收费， 值是1时是收费，0是免费
is_vip : 是否是vip， 1时是vip， 0时不是vip，vip电影价格打九折
"""
# 项目需求
"""
1 三次登陆，必须以nb开头，密码必须大于8小于16
2 登陆成功后，打印所有电影，
3 选择电影
4 看电影是否收费
5 不收费直接下载
6 看是否是vip，是vip打88折
6 收费电影，看电影的价格是否大于你的钱数，大于钱数，就退出
7 不大于时，选择是否付款
8 如果付款，在你的金额里减去电影的价格，并打印金额，下载电影
"""
user_dic = {"name": "NBlynn", "password": "NBlynn123", "money": 9999, "is_vip": 1}
movie_list = [
    {"movie_name": "金色", "status": 1, "money": 10000},
    {"movie_name": "三国", "status": 0, "money": 0},
    {"movie_name": "红楼", "status": 1, "money": 100}
]


def downLoad():
    scale = 100;
    print("执行开始".center(scale // 2, "="))
    start = time.perf_counter()
    for i in range(scale + 1):
        a = "*" * i
        b = "." * (scale - i)
        c = (i / scale) * 100
        c1 = (i + (1 - i) / 2) ** 8
        dur = time.perf_counter() - start
        print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c, a, b, dur), end="")
        time.sleep(0.03)
    print("\n" + "执行结束".center(scale // 2, "-"))


def login():
    a = 0
    moviceid = 1
    while a < 3:
        a = a + 1
        rootname = input("name:")
        rootpasswd = input("pass:")
        if rootname.startswith('nb') and len(rootpasswd) < 16:
            print("True")
            for i, b in enumerate(movie_list):
                print(b.get("movie_name"))
            choice = input("movicename:")
            for i, b in enumerate(movie_list):
                if b.get("movie_name") == choice:
                    moviceid = i
            if movie_list[moviceid]["status"]:
                buymovice = input("do you want buy  ? yes/no")
                if buymovice == "yes":
                    if user_dic.get("is_vip"):
                        if movie_list[moviceid]["money"] * 0.88 < user_dic["money"]:
                            user_dic["money"] -= movie_list[moviceid]["money"] * 0.88
                            print(user_dic["money"])
                            downLoad()
                        else:
                            print("你没钱了")
                    else:
                        if movie_list[moviceid]["money"] < user_dic["money"]:
                            user_dic["money"] -= movie_list[moviceid]["money"] * 0.88
                            print(user_dic["money"])
                            downLoad()
                        else:
                            print("你没钱了")
                else:
                    print("没钱看个屁")
            else:
                downLoad()
        else:
            print("False")
            continue


if __name__ == '__main__':
    print("login")
    is_login = login()
"""
status : 1时，收费，0时，免费
is_vip ： 1 时 是vip ，0时非vip
"""
